<template>
    <el-card class="patient-info__container" shadow="always">
        <el-form size="large">
            <el-form-item label="性别">
                <el-radio-group v-model="patientInfo.sex" aria-label="患者性别">
                    <el-radio-button value="男">男</el-radio-button>
                    <el-radio-button value="女">女</el-radio-button>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="年龄">
                <el-slider 
                    aria-label="年龄" 
                    v-model="patientInfo.age" 
                    style="max-width: 580px; margin-right: 20px;" 
                    :min=0 :max=100 :precision=0 
                />
                <el-input-number
                    aria-label="年龄"
                    v-model="patientInfo.age"
                    size="default" 
                    :max=100 :min=0 :precision=0 
                />
                <span class="unit">岁</span>
            </el-form-item>
            <el-form-item label="体温">
                <el-slider 
                    aria-label="体温" 
                    v-model="patientInfo.temperature" 
                    style="max-width: 580px; margin-right: 20px;" 
                    :min=34 :max=42 :step=0.1 :precision=1 
                    :marks="{
                    36: '36°C',
                    37.3: '37.3°C',
                    38.5: '38.5°C',
                    40: '40°C' 
                    }" 
                />
                <el-input-number
                    aria-label="体温"
                    v-model="patientInfo.temperature"
                    size="default" 
                    :max=42 :min=34 :precision=1 :step=0.1
                />
                <span class="unit">°C</span>
            </el-form-item>
            <el-form-item label="血压" class="hypertension">
                <el-input-number 
                    aria-label="收缩压"
                    v-model="patientInfo.hypertension_high" 
                    :max=280 :min=0 :precision=0 
                />
                <span class="slash">/</span>
                <el-input-number
                    aria-label="舒张压"
                    v-model="patientInfo.hypertension_low" 
                    :max=280 :min=0 :precision=0 
                />
                <span class="unit">mmHg</span>
            </el-form-item>
            <el-form-item label="心率" class="pulse">
                <el-input-number 
                    aria-label="心率"
                    v-model="patientInfo.pulse" 
                    :max=220 :min=0 :precision=0
                />
                <span class="unit">bpm</span>
            </el-form-item>
        </el-form>
        <div class="patient-info__btns">
            <el-button type="primary" @click="onNextStep">
                下一步
            </el-button>
        </div>
    </el-card>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { usePatientStore } from '../../store/patient';
import { use } from 'marked';
import { pa } from 'element-plus/es/locale/index.mjs';

const emit = defineEmits(['nextStep'])

const patientStore = usePatientStore();
const { patientInfo } = patientStore;

const onNextStep = () => {
    emit('nextStep');
    patientStore.setPatientInfo(patientInfo);
}

</script>

<style lang="scss" scoped>
.patient-info__container {
    .slash {
        margin: 0 10px;
        font-size: 2rem;
        font-weight: bold;
    }
    .unit {
        margin-left: 10px;
        font-size: 1rem;
        font-weight: bold;
    }
}
.patient-info__btns {
    display: flex;
    justify-content: end;
    margin-top: 20px;
}
</style>

<style lang="scss">
.patient-info__container {
    .el-form-item__label {
        font-size: 1rem;
        font-weight: bold;
        margin-right: 10px;
    }
    .el-form-item {
        margin-bottom: 3rem;
    }
    .el-slider__marks-text {
        margin-top: 5px;
    }
    .el-input__inner {
        font-size: 1.5rem;
        width: 15px;
    }
}
</style>